﻿using Microsoft.Office.Interop.Excel;
using System;
using System.Reflection;

namespace TecBaseObjects.Base {

    public class CalculationSheet : AbstractProjectSheet {

        #region Construtor

        public CalculationSheet(Worksheet sh): base(sh) {
           
        }

        #endregion

        #region Properties

        public int CustomerGroup {
            get {
                Range r1 = MySheet.Cells[1, "D"];
                int ret = 1;
                if (r1.Value != null) {
                    int.TryParse(r1.Value.ToString(), out ret);
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[1, "D"];
                r1.Value = value;
            }
        }

        public double Distance {
            get {
                Range r1 = MySheet.Cells[1, "J"];
                double ret = 0.0;
                if (r1.Value != null) {
                    double.TryParse(r1.Value.ToString(), out ret);
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[1, "J"];
                r1.Value = value;
            }
        }

        public string Town {
            get {
                Range r1 = MySheet.Cells[2, "F"];
                string ret = "";
                if (r1.Value != null) {
                    ret = r1.Value.ToString();
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[2, "F"];
                r1.Value = value;
            }
        }

        public string ZipCode {
            get {
                Range r1 = MySheet.Cells[2, "E"];
                string ret = "";
                if (r1.Value != null) {
                    ret = r1.Value.ToString();
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[2, "E"];
                r1.Value = value;
            }
        }

        public string ProjectName {
            get {
                Range r1 = MySheet.Cells[2, "C"];
                string ret = "";
                if (r1.Value != null) {
                    ret = r1.Value.ToString();
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[2, "C"];
                r1.Value = value;
            }
        }

        public string ProjectNumber {
            get {
                Range r1 = MySheet.Cells[2, "D"];
                string ret = "";
                if (r1.Value != null) {
                    ret = r1.Value.ToString();
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[2, "D"];
                r1.Value = value;
            }
        }

        public string Street {
            get {
                Range r1 = MySheet.Cells[2, "G"];
                string ret = "";
                if (r1.Value != null) {
                    ret = r1.Value.ToString();
                }
                return ret;
            }
            set {
                Range r1 = MySheet.Cells[2, "G"];
                r1.Value = value;
            }
        }

        #endregion
        
    }
}
